import 'package:flutter_rider/module/mine/models/truck_model.dart';
import 'package:flutter_rider/module/mine/provider/number_car_provider.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
/// 这种简便做法但是官方介意自定义类都用StateNotifier写一个类 基础类型用StateProvider比较好
final stopStationProvider = StateProvider.autoDispose((ref) {
  return TruckParkModel(null, "请选择停靠点");
});

///是否有上传图片了
final outsideImageProvider = StateProvider.autoDispose((ref) {
  return false;
});

///用来判断是否可以提交
final submitOutsideProvider = StateProvider.autoDispose((ref) {
  //加上这一行才会监听numberCarProvider
  ref.watch(numberCarProvider);
  var isNumberCar = ref.read(numberCarProvider.notifier).isNumberCar();
  var isId = ref.watch(stopStationProvider).id != null;
  var isOutsideImage = ref.watch(outsideImageProvider);

  return isNumberCar && isId && isOutsideImage;
});

///存储选中定位信息
final positionProvider = StateProvider((ref) {
  return const LatLng(0,0);
});
